<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>模板管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function deleteTemplate(templateId,href){
			var url = "${ctx}/ins/insTemplate/validDelete";
			var deleteUrl = "${ctx}/ins/insTemplate/delete?id="+templateId;
			var flag = false;
			$.ajax({
	            type: 'POST',
	            url : url,
	            async:false,
	            data: {"id":templateId},             //获取表单数据
	            success : function(data) {
	            	if(data == "true"){
	            		confirmx("确认删除该模板吗？",href);
	            	}else{
	            		alertx("该模板尚在绑定中，不能删除！");
	            		return false;
	            	}
	            },
	            error : function(data){
	            	alertx("无权限");
	            	return false;
	            }
	        });
			return false;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ins/insTemplate/">模板列表</a></li>
		<shiro:hasPermission name="ins:insTemplate:edit"><li><a href="${ctx}/ins/insTemplate/form">模板添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="insTemplate" action="${ctx}/ins/insTemplate/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>模板名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>模板名称</th>
				<th>备注</th>
				<th>创建时间</th>
				<th>创建人</th>
				<shiro:hasPermission name="ins:insTemplate:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="insTemplate">
			<tr>
				<td><a href="${ctx}/ins/insTemplate/form?id=${insTemplate.id}">
					${insTemplate.name}
				</a></td>
				<td>
					${insTemplate.remarks}
				</td>
				<td>
					<fmt:formatDate value="${insTemplate.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${insTemplate.createBy.name}
				</td>
				<shiro:hasPermission name="ins:insTemplate:edit"><td>
					<a href="${ctx}/ins/insTemplate/delete?id=${insTemplate.id}" onclick="return deleteTemplate('${insTemplate.id}',this.href);">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>